# DBus 计数器示例 Makefile

# 编译器设置
CC = gcc
CFLAGS = -Wall -Werror -g

# DBus 库相关设置
# 包含路径
DBUS_INCLUDE = $(shell pkg-config --cflags dbus-1) -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include
# 链接库
DBUS_LIBS = $(shell pkg-config --libs dbus-1) -ldbus-1

# 目标文件
TARGETS = counter_service counter_client

# 默认目标
all: $(TARGETS)

# 编译服务端程序
counter_service: counter_service.c
	$(CC) $(CFLAGS) -o $@ $< $(DBUS_INCLUDE) $(DBUS_LIBS)

# 编译客户端程序
counter_client: counter_client.c
	$(CC) $(CFLAGS) -o $@ $< $(DBUS_INCLUDE) $(DBUS_LIBS)

# 清理编译生成的文件
clean:
	rm -f $(TARGETS)

# 安装目标（可选）
install:
	install -m 755 counter_service /usr/local/bin/
	install -m 755 counter_client /usr/local/bin/

# 帮助信息
help:
	@echo "可用目标："
	@echo "  all       - 编译所有程序（默认）"
	@echo "  counter_service - 编译服务端程序"
	@echo "  counter_client - 编译客户端程序"
	@echo "  clean     - 清理编译生成的文件"
	@echo "  install   - 安装程序到系统"
	@echo "  help      - 显示此帮助信息"

# 声明伪目标
.PHONY: all clean install help